<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<input type="text"/>
<button>发送</button>
<script>
  let btn = document.querySelector('button');
  let input = document.querySelector('input');

  // 不计时的方法
  // btn.addEventListener('click', function () {
  //   // send
  //   btn.disabled = true;
  //   setTimeout(function () {
  //     btn.disabled = false;
  //   }, 5000)
  // })

  btn.addEventListener('click', function () {
    // send
    btn.disabled = true;
    var time = 5;
    var timer = setInterval(function () {
      if (time === 0) {
        btn.disabled = false;
        btn.innerHTML = '发送';
        clearInterval(timer);
      } else {

        btn.innerHTML = '还需要' + time + '秒';
        time--;
      }
    }, 1000)
  })
</script>
</body>
</html>